<template>
    <div>
        用户名：<input type="text" placeholder="username" v-model="username">
        密码: <input type="text" placeholder="pwd" v-model="pwd">
        <button @click="sub">登录</button>
    </div>
</template>
<script>
export default {
    data(){
        return {
            username:'',
            pwd:''
        }
    },
    methods:{
        sub(){
            this.$http.post('/api/login',{username:this.username,pwd:this.pwd}).then(res => {
                if(res.data.code === 1){
                    localStorage.setItem('username',this.username);
                    this.$router.go(-1);
                }
            })
        }
    }
}
</script>
